package website.lucaswork.survey.mvc.forms;

import org.hibernate.validator.constraints.NotEmpty;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.multipart.MultipartFile;
import website.lucaswork.survey.core.entities.Survey;
import website.lucaswork.survey.core.entities.User;
import website.lucaswork.survey.core.utils.DefaultValues;
import website.lucaswork.survey.mvc.validators.ImageFile;
import website.lucaswork.survey.mvc.validators.LocalDateTimeFormat;
import website.lucaswork.survey.mvc.validators.SurveyTimeRange;
import website.lucaswork.survey.mvc.validators.UniqueSurveyTitlePerUser;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.time.LocalDateTime;

@SurveyTimeRange
public class CreateSurveyForm {
    @NotEmpty(message = "Title can not be empty")
    @Size(max = 30, message = "Title can not be longer than 30 chars")
    @UniqueSurveyTitlePerUser
    private String title;
    @ImageFile
    private MultipartFile cover;
    @ImageFile
    private MultipartFile bg;
    private String coverUrl;
    private String bgUrl;
    @Size(max = 100, message = "Text before survey can not be longer than 100 chars")
    private String frontText;
    @Size(max = 100, message = "Text after survey can not be longer than 100 chars")
    private String endText;
    @NotEmpty(message = "Start Time can not be empty")
    @LocalDateTimeFormat
    private String startTime;
    @NotEmpty(message = "End Time can not be empty")
    @LocalDateTimeFormat
    private String endTime;
    @Size(max = 300, message = "Description can not be longer than 300 chars")
    private String description;

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public MultipartFile getCover() {
        return cover;
    }

    public void setCover(MultipartFile cover) {
        this.cover = cover;
    }

    public MultipartFile getBg() {
        return bg;
    }

    public void setBg(MultipartFile bg) {
        this.bg = bg;
    }

    public String getCoverUrl() {
        return coverUrl;
    }

    public void setCoverUrl(String coverUrl) {
        this.coverUrl = coverUrl;
    }

    public String getBgUrl() {
        return bgUrl;
    }

    public void setBgUrl(String bgUrl) {
        this.bgUrl = bgUrl;
    }

    public String getFrontText() {
        return frontText;
    }

    public void setFrontText(String frontText) {
        this.frontText = frontText;
    }

    public String getEndText() {
        return endText;
    }

    public void setEndText(String endText) {
        this.endText = endText;
    }

    public String getStartTime() {
        return startTime;
    }

    public void setStartTime(String startTime) {
        this.startTime = startTime;
    }

    public String getEndTime() {
        return endTime;
    }

    public void setEndTime(String endTime) {
        this.endTime = endTime;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @Override
    public String toString() {
        return "CreateSurveyForm{" +
                "coverUrl='" + coverUrl + '\'' +
                ", bgUrl='" + bgUrl + '\'' +
                ", frontText='" + frontText + '\'' +
                ", endText='" + endText + '\'' +
                ", startTime='" + startTime + '\'' +
                ", endTime='" + endTime + '\'' +
                ", description='" + description + '\'' +
                '}';
    }

}
